<?php

$data = array();
$sec_id = $_GET['sec_id'];
$sql = "select * from tb_sec NATURAL JOIN tb_teacher NATURAL JOIN tb_subject WHERE sec_id='{$sec_id}'";
$result = $dbfunc->query($sql);
$data['sec'] = mysql_fetch_assoc($result);
$result = $dbfunc->query("SELECT *,tb_student.* FROM tb_student 
        LEFT JOIN tb_reg ON tb_student.student_id = tb_reg.student_id 
        LEFT JOIN tb_plan ON tb_plan.sec_id = '{$sec_id}' AND tb_student.room_id = tb_plan.room_id");
while($item = mysql_fetch_assoc($result)){
	$data['stu'][] = $item;
}
echo json_encode($data);